package org.base.dao.common;

import java.beans.Transient;
import java.util.Collections;
import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.plugins.pagination.Pagination;

public class Page<T> extends Pagination{
	
	private static final long serialVersionUID = 1L;
	
	private String orderBy;
	
	private boolean sortAsc = false;

	/**
	 * 查询数据列表
	 */
	private List<T> records = Collections.emptyList();
	/**
	 * 查询条件
	 */
	private Map<String, Object> condition;

	public Page(int current, int size) {
	    super(current, size);
	}


	public Page(int current, int size, String orderBy, boolean sortAsc) {
	    this(current, size);
	    this.orderBy = orderBy;
	    this.sortAsc = sortAsc;
	}

	public List<T> getRecords() {
	    return records;
	}

	public Page<T> setRecords(List<T> records) {
	    this.records = records;
	    return this;
	}
	
	@Transient
	public String getOrderBy() {
		return orderBy;
	}


	public void setOrderBy(String orderBy) {
		this.orderBy = orderBy;
	}
	
	@Transient
	public boolean isSortAsc() {
		return sortAsc;
	}

	public void setSortAsc(boolean sortAsc) {
		this.sortAsc = sortAsc;
	}


	@Transient
	public Map<String, Object> getCondition() {
	    return condition;
	}

	public Page<T> setCondition(Map<String, Object> condition) {
	    this.condition = condition;
	    return this;
	}

	@Override
	public String toString() {
	    StringBuilder pg = new StringBuilder();
	    pg.append(" Page:{ [").append(super.toString()).append("], ");
	    if (records != null) {
	        pg.append("records-size:").append(records.size());
	    } else {
	        pg.append("records is null");
	    }
	    return pg.append(" }").toString();
	}

}
